﻿using System;

namespace CommonServiceManager.Configuration
{
	/// <summary>
	/// A pair of a type and an implementation key.
	/// </summary>
	public class KeyedType
	{
		/// <summary>
		/// Create a new pair of a <see cref="Type"/> and a <see cref="string"/> implementation key.
		/// </summary>
		/// <param name="type">The type of the parameter selected for Dependency Injection.</param>
		/// <param name="implementationKey">The implementation key if the type has more than one implementation in the system.</param>
		/// <exception cref="ArgumentNullException"><paramref name="type"/> cannot be null</exception>
		public KeyedType(Type type, string implementationKey = null)
		{
			if (type == null) throw new ArgumentNullException("type");

			Type = type;
			ImplementationKey = implementationKey;
		}

		/// <summary>
		/// The type of a parameter to a constructor or method selected for Dependency Injection.
		/// This has to match the types of the parameters on the intended constructor or method each one in sequence.
		/// </summary>
		public Type Type { get; set; }

		/// <summary>
		/// The implementation key if the parameter type has more than one implementation in the system.
		/// </summary>
		public string ImplementationKey { get; set; }
	}
}